package cn.jbolt.controller;

import com.jfinal.kit.StrKit;

import cn.jbolt.common.base.BaseController;
import cn.jbolt.common.exception.AppException;
import cn.jbolt.dao.model.SysUser;


public class LoginController extends BaseController {
	public void login() {
		String username = getPara("username");
		String password = getPara("password");
		SysUser userdb = SysUser.dao.findFirst("select * from sys_user where username = ? ", username);
		if (userdb == null) {
			throw new AppException("用户不存在!");
		}

		String passwordDb = userdb.getPassword();
		if (StrKit.isBlank(passwordDb) || !passwordDb.equals(password)) {
			throw new AppException("密码不正确!");
		}
		renderJsonResult(userdb);
	}
	
	
}
